﻿/* ######################################## *\
 * ### Copyright (C) 2009 AJ Ravindiran ### *
\* ######################################## */
using System;
using System.IO;

namespace AJRavindiran.Jolt.RuneScape.Models.World
{
    /// <summary>
    /// Represents a map data packer.
    /// </summary>
    public class MapDataPacker
    {
        public static void Pack()
        {
            try
            {
                FileStream stream = File.Create(@".\bin\data\mapdata\regions.dat");
                BinaryWriter writer = new BinaryWriter(stream);

                for (int i = 6000; i < 16000; i++)
                {
                    if (File.Exists(@".\bin\data\mapdata\packed\" + i + ".txt"))
                    {
                        TextReader reader = new StreamReader(@".\bin\data\mapdata\packed\" + i + ".txt");
                        writer.Write(i);

                        for (int j = 0; j < 4; j++)
                            writer.Write(int.Parse(reader.ReadLine()));

                        reader.Close();
                    }
                }
                writer.Close();
                stream.Close();
            }
            catch (Exception ex)
            {
                Jolt.GetLog().WriteException(ex);
            }
        }
    }
}
